/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 *
 * @author Elderry
 */
public class MainFrame extends javax.swing.JFrame {

    /**
     * Creates new form NewJFrame
     */
    public MainFrame() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSplitPaneHorizontal = new javax.swing.JSplitPane();
        jSplitPaneVertical = new javax.swing.JSplitPane();
        jInternalFrameEditor = new javax.swing.JInternalFrame();
        jTabbedPaneEditor = new javax.swing.JTabbedPane();
        jScrollPaneEditor = new javax.swing.JScrollPane();
        jTextPaneEditor = new javax.swing.JTextPane();
        jInternalFrameProblem = new javax.swing.JInternalFrame();
        jTabbedPaneProblems = new javax.swing.JTabbedPane();
        jScrollPaneProblems = new javax.swing.JScrollPane();
        jTableProblems = new javax.swing.JTable();
        jInternalFrameAnalysis = new javax.swing.JInternalFrame();
        jTabbedPaneAnalysis = new javax.swing.JTabbedPane();
        jScrollPaneLexical = new javax.swing.JScrollPane();
        jTableLexical = new javax.swing.JTable();
        jScrollPaneSyntax = new javax.swing.JScrollPane();
        jTreeSyntax = new javax.swing.JTree();
        jScrollPaneSemantics = new javax.swing.JScrollPane();
        jTableSemantics = new javax.swing.JTable();
        jScrollPaneAssembly = new javax.swing.JScrollPane();
        jTextPaneAssembly = new javax.swing.JTextPane();
        jFileChooser1 = new javax.swing.JFileChooser();
        jToolBar1 = new javax.swing.JToolBar();
        jButtonCompile = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuItemOpen = new javax.swing.JMenuItem();
        jMenuItemSaveAs = new javax.swing.JMenuItem();
        jMenuEdit = new javax.swing.JMenu();
        jMenuItemUndo = new javax.swing.JMenuItem();
        jMenuItemRedo = new javax.swing.JMenuItem();
        jMenuCompile = new javax.swing.JMenu();
        jMenuItemCompile = new javax.swing.JMenuItem();
        jMenuType = new javax.swing.JMenu();
        jCheckBoxMenuItemLexical = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItemSyntax = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItemSematics = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItemAssembly = new javax.swing.JCheckBoxMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Tripilller");
        setPreferredSize(new java.awt.Dimension(1280, 720));

        jSplitPaneHorizontal.setDividerLocation(950);
        jSplitPaneHorizontal.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N

        jSplitPaneVertical.setDividerLocation(450);
        jSplitPaneVertical.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jInternalFrameEditor.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jInternalFrameEditor.setClosable(true);
        jInternalFrameEditor.setTitle("Editor");
        jInternalFrameEditor.setVisible(true);

        jScrollPaneEditor.setViewportView(jTextPaneEditor);

        jTabbedPaneEditor.addTab("New File", jScrollPaneEditor);

        javax.swing.GroupLayout jInternalFrameEditorLayout = new javax.swing.GroupLayout(jInternalFrameEditor.getContentPane());
        jInternalFrameEditor.getContentPane().setLayout(jInternalFrameEditorLayout);
        jInternalFrameEditorLayout.setHorizontalGroup(
            jInternalFrameEditorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneEditor, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 943, Short.MAX_VALUE)
        );
        jInternalFrameEditorLayout.setVerticalGroup(
            jInternalFrameEditorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneEditor, javax.swing.GroupLayout.DEFAULT_SIZE, 416, Short.MAX_VALUE)
        );

        jSplitPaneVertical.setTopComponent(jInternalFrameEditor);

        jInternalFrameProblem.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jInternalFrameProblem.setClosable(true);
        jInternalFrameProblem.setTitle("Problems");
        jInternalFrameProblem.setVisible(true);

        jTableProblems.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jTableProblems.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPaneProblems.setViewportView(jTableProblems);

        jTabbedPaneProblems.addTab("Problems", jScrollPaneProblems);

        javax.swing.GroupLayout jInternalFrameProblemLayout = new javax.swing.GroupLayout(jInternalFrameProblem.getContentPane());
        jInternalFrameProblem.getContentPane().setLayout(jInternalFrameProblemLayout);
        jInternalFrameProblemLayout.setHorizontalGroup(
            jInternalFrameProblemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneProblems, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 943, Short.MAX_VALUE)
        );
        jInternalFrameProblemLayout.setVerticalGroup(
            jInternalFrameProblemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneProblems, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)
        );

        jSplitPaneVertical.setRightComponent(jInternalFrameProblem);

        jSplitPaneHorizontal.setLeftComponent(jSplitPaneVertical);

        jInternalFrameAnalysis.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jInternalFrameAnalysis.setClosable(true);
        jInternalFrameAnalysis.setTitle("Analysis");
        jInternalFrameAnalysis.setVisible(true);

        jTableLexical.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jTableLexical.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPaneLexical.setViewportView(jTableLexical);

        jTabbedPaneAnalysis.addTab("Lexical", jScrollPaneLexical);

        jTreeSyntax.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jScrollPaneSyntax.setViewportView(jTreeSyntax);

        jTabbedPaneAnalysis.addTab("Syntax", jScrollPaneSyntax);

        jTableSemantics.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jTableSemantics.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPaneSemantics.setViewportView(jTableSemantics);

        jTabbedPaneAnalysis.addTab("Semantics", jScrollPaneSemantics);

        jTextPaneAssembly.setEditable(false);
        jTextPaneAssembly.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jScrollPaneAssembly.setViewportView(jTextPaneAssembly);

        jTabbedPaneAnalysis.addTab("Assembly", jScrollPaneAssembly);

        javax.swing.GroupLayout jInternalFrameAnalysisLayout = new javax.swing.GroupLayout(jInternalFrameAnalysis.getContentPane());
        jInternalFrameAnalysis.getContentPane().setLayout(jInternalFrameAnalysisLayout);
        jInternalFrameAnalysisLayout.setHorizontalGroup(
            jInternalFrameAnalysisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneAnalysis, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
        );
        jInternalFrameAnalysisLayout.setVerticalGroup(
            jInternalFrameAnalysisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneAnalysis, javax.swing.GroupLayout.DEFAULT_SIZE, 627, Short.MAX_VALUE)
        );

        jSplitPaneHorizontal.setRightComponent(jInternalFrameAnalysis);

        jFileChooser1.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jFileChooser1.setEnabled(false);
        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser1ActionPerformed(evt);
            }
        });

        jToolBar1.setRollover(true);

        jButtonCompile.setFont(new java.awt.Font("Segoe UI", 0, 13)); // NOI18N
        jButtonCompile.setText("Compile");
        jButtonCompile.setFocusable(false);
        jButtonCompile.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonCompile.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonCompile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCompileActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonCompile);

        jMenuFile.setText("File");

        jMenuItemOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemOpen.setText("Open");
        jMenuItemOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOpenActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemOpen);

        jMenuItemSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemSaveAs.setText("Save As");
        jMenuItemSaveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSaveAsActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemSaveAs);

        jMenuBar1.add(jMenuFile);

        jMenuEdit.setText("Edit");

        jMenuItemUndo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemUndo.setText("Undo");
        jMenuEdit.add(jMenuItemUndo);

        jMenuItemRedo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Y, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemRedo.setText("Redo");
        jMenuEdit.add(jMenuItemRedo);

        jMenuBar1.add(jMenuEdit);

        jMenuCompile.setText("Compile");

        jMenuItemCompile.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
        jMenuItemCompile.setText("Compile");
        jMenuItemCompile.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemCompileActionPerformed(evt);
            }
        });
        jMenuCompile.add(jMenuItemCompile);

        jMenuType.setText("Compile Type");

        jCheckBoxMenuItemLexical.setSelected(true);
        jCheckBoxMenuItemLexical.setText("Lexical Analysis");
        jMenuType.add(jCheckBoxMenuItemLexical);

        jCheckBoxMenuItemSyntax.setSelected(true);
        jCheckBoxMenuItemSyntax.setText("Syntax Analysis");
        jMenuType.add(jCheckBoxMenuItemSyntax);

        jCheckBoxMenuItemSematics.setSelected(true);
        jCheckBoxMenuItemSematics.setText("Semantics Analysis");
        jMenuType.add(jCheckBoxMenuItemSematics);

        jCheckBoxMenuItemAssembly.setSelected(true);
        jCheckBoxMenuItemAssembly.setText("Assembly Geneartion");
        jMenuType.add(jCheckBoxMenuItemAssembly);

        jMenuCompile.add(jMenuType);

        jMenuBar1.add(jMenuCompile);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPaneHorizontal, javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 288, Short.MAX_VALUE)
                    .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 288, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPaneHorizontal, javax.swing.GroupLayout.DEFAULT_SIZE, 662, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 149, Short.MAX_VALUE)
                    .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 149, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItemOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOpenActionPerformed
      int returnVal = jFileChooser1.showOpenDialog(this);
        if (returnVal == jFileChooser1.APPROVE_OPTION) {
            File file = jFileChooser1.getSelectedFile();
            try {
                jTextPaneEditor.read(new FileReader(file.getAbsolutePath()), null);
            } catch (IOException ex) {
                System.out.println("problem accessing file"
                        + file.getAbsolutePath());
            }
        } else {
            System.out.println("File access cancelled by user.");
        }
    }//GEN-LAST:event_jMenuItemOpenActionPerformed

    private void jMenuItemSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSaveAsActionPerformed
       int returnVal = jFileChooser1.showOpenDialog(this);
        if (returnVal == jFileChooser1.APPROVE_OPTION) {
            File file = jFileChooser1.getSelectedFile();
            try {
                FileOutputStream fos = new FileOutputStream(new File(
                        file.getAbsolutePath()));
                OutputStreamWriter osw = new OutputStreamWriter(fos);
                String saveString = jTextPaneEditor.getText().replaceAll("\n",
                        "\r\n");
                osw.write(saveString);
                osw.flush();
                osw.close();
            } catch (IOException ex) {
                System.out.println("problem accessing file"
                        + file.getAbsolutePath());
            }
        } else {
            System.out.println("File access cancelled by user.");
        }
    }//GEN-LAST:event_jMenuItemSaveAsActionPerformed

    private void jMenuItemCompileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCompileActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemCompileActionPerformed

    private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jFileChooser1ActionPerformed

    private void jButtonCompileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCompileActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonCompileActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCompile;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemAssembly;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemLexical;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemSematics;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemSyntax;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JInternalFrame jInternalFrameAnalysis;
    private javax.swing.JInternalFrame jInternalFrameEditor;
    private javax.swing.JInternalFrame jInternalFrameProblem;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMenuCompile;
    private javax.swing.JMenu jMenuEdit;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenuItem jMenuItemCompile;
    private javax.swing.JMenuItem jMenuItemOpen;
    private javax.swing.JMenuItem jMenuItemRedo;
    private javax.swing.JMenuItem jMenuItemSaveAs;
    private javax.swing.JMenuItem jMenuItemUndo;
    private javax.swing.JMenu jMenuType;
    private javax.swing.JScrollPane jScrollPaneAssembly;
    private javax.swing.JScrollPane jScrollPaneEditor;
    private javax.swing.JScrollPane jScrollPaneLexical;
    private javax.swing.JScrollPane jScrollPaneProblems;
    private javax.swing.JScrollPane jScrollPaneSemantics;
    private javax.swing.JScrollPane jScrollPaneSyntax;
    private javax.swing.JSplitPane jSplitPaneHorizontal;
    private javax.swing.JSplitPane jSplitPaneVertical;
    private javax.swing.JTabbedPane jTabbedPaneAnalysis;
    private javax.swing.JTabbedPane jTabbedPaneEditor;
    private javax.swing.JTabbedPane jTabbedPaneProblems;
    private javax.swing.JTable jTableLexical;
    private javax.swing.JTable jTableProblems;
    private javax.swing.JTable jTableSemantics;
    private javax.swing.JTextPane jTextPaneAssembly;
    private javax.swing.JTextPane jTextPaneEditor;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTree jTreeSyntax;
    // End of variables declaration//GEN-END:variables
}
